package cn.niit.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

//开启 OpenApi
@EnableOpenApi
@Configuration
public class SwaggerConfig {

    public Docket docket(){
        Docket docket = new Docket(DocumentationType.OAS_30);
        docket.apiInfo(apiInfo())
                .select()
                //.apis(RequestHandlerSelectors.basePackage("cn.niit.smbms.controller.api"))
                .apis(RequestHandlerSelectors.withClassAnnotation(ResponseBody.class))
                //any扫描全部，none都不扫描
                //过滤的路径
                .paths(PathSelectors.any()).build();
        return docket;
    }
    //接口信息
    private ApiInfo apiInfo(){
        Contact contact = new Contact("作者 name", "作者URL","作者的邮箱");
        ApiInfo apiInfo = new ApiInfo(
                "Swagger3接口文档",
                "SpringBoot 整合 Swagger3 生成接口文档!",
                "1.0.0",
                "termsOfServiceUrl",
                contact,
                "这里是license",
                "这里是licenseUrl",
                new ArrayList());
        return apiInfo;
    }

}